<template>
  <div class="container">
    <img :src="headerImg" class="headerImg"/>
    <div class="title">{{titleNumber}}人参与</div>
    <ul class="peopleImg clearfix">
      <li v-for="imgSrc in imagesList">
        <img :src="imgSrc"/>
      </li>
    </ul>
    <div class="more" @click="more" v-if="showMore">加载更多</div>
  </div>
</template>
<script>

export default {
  components: {
  },

  data () {
    return {
      page:0,
      limit:60,
      ad_id:"",
      headerImg:"",
      titleNumber:"",
      imagesList:[],
      type:'',
      showMore:true
    }
  },
  onShow(){
    this.page=0;
    this.imagesList=[];
    this.getImagesData();
  },
  onLoad(option){
    console.log(option.id,option.type)
    this.ad_id=option.id;
    this.type=option.type
  },
  methods:{
    async getImagesData(){
      let res;
      let data;
      let tag=false;
      this.showMore=true;
      let userToken=wx.getStorageSync('userToken')
      console.log(this.type)
      if(this.type=='luckDraw'){
         res=await this.$request.getData('https://diy.zoomyoung.cn/api/activity/get-activity-join-list',{ad_id:this.ad_id,page:this.page,limit:this.limit});
          data=res.data.data;
          [this.headerImg,this.titleNumber]=[data.img_url,data.join_count];
          this.imagesList=this.imagesList.concat(data.join_list);
          if(data.join_list.length<= 0){
            tag=true
           }
      }else if(this.type=='support'){
         res=await this.$request.getData('https://diy.zoomyoung.cn/api/activity/get-activity-support-list',{ad_id:this.ad_id,page:this.page,limit:this.limit,user_token:userToken});
         data=res.data.data;
         [this.headerImg,this.titleNumber]=[data.img_url,data.support_count];
         this.imagesList=this.imagesList.concat(data.support_list);
         if(data.support_list.length<= 0){
          tag=true
         }
      }else if(this.type=='winning'){
         res=await this.$request.getData('https://diy.zoomyoung.cn/api/activity/get-activity-win-list',{ad_id:this.ad_id,page:this.page,limit:this.limit});
         console.log(res)
         data=res.data.data;
         [this.headerImg,this.titleNumber]=[data.img_url,data.winning_count];
         this.imagesList=this.imagesList.concat(data.winning_list);
         if(data.winning_list.length<= 0){
          tag=true
         }
      }
      if(tag){
         this.showMore=false;
         this.$currency.showToast('数据加载中...','none',"")
      }
    },
    more(){
      this.page++;
      this.getImagesData();
    }
  }
}
</script>

<style scoped>
.container{width: 100%;}
/*.headerImg{width: 342.5px;height: 99px;display: block;margin: 0px auto;}*/
.headerImg{width: 100%;height: 187.5px;display: block;margin: 0px auto;}
.title{width: 100%;height: 17px;line-height: 17px;text-align: center;color: #999999;font-size: 14px;margin-bottom: 30px;margin-top: 10px}
.peopleImg li{width: 30px;height: 30px;margin-left: 15px;float: left;margin-bottom: 10px;}
.peopleImg li img{width: 100%;height: 100%;}
.more{width: 56.5px;height: 16.5px;line-height: 16.5px;margin: 60px auto;font-size: 14px;color: #3399FF;}
</style>
